package org.volicy.scheduled;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.SchedulingConfiguration;
import org.volicy.scheduled.controller.ScheduledController;
import org.volicy.scheduled.dao.ScheduledMapper;
import org.volicy.scheduled.processor.ScheduledPostProcessor;
import org.volicy.scheduled.register.ScheduledRegistrar;
import org.volicy.scheduled.sch.ScheduleHandler;

/**
 * @Author: volicy.xu
 * @Date: 2021/9/19
 */
@Configuration
@AutoConfigureAfter(SchedulingConfiguration.class)
@Import(ScheduledRegistrar.class)
public class ScheduledManageAutoConfiguration {
    private Logger logger = LoggerFactory.getLogger(ScheduledManageAutoConfiguration.class);

    @Bean
    public ScheduledPostProcessor scheduledPostProcessor() {
        logger.info("scheduledPostProcessor - init --");
        return new ScheduledPostProcessor();
    }


    @Bean(initMethod = "init")
    public ScheduleHandler scheduleHandle(ScheduledMapper scheduledMapper) {
        return new ScheduleHandler(scheduledMapper);
    }


    /**
     *
     * 页面 controller
     *
     * @return
     */
    @Bean(name = "scheduledController")
    public ScheduledController scheduledController(){
        return new ScheduledController();
    }
}
